package com.qfmy.app.mapper.novel;

import com.qfmy.model.entity.novel.ReadTime;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.app.mapper.novel
 * @date 2025/4/15
 * @description 阅读记录
 */
@Mapper
@SuppressWarnings("all")
public interface ReadTimeMapper {

    /**
     * 查询阅读时长
     * @param userId
     * @return
     */
    @Select("select day_time from read_time where user_id = #{userId}")
    Integer getReadTime(Integer userId);

    /**
     * 查询阅读时长
     * @param userId
     * @return
     */
    @Select("select id,day_time from read_time where user_id = #{userId}")
    ReadTime selectByRead(Integer userId);

    /**
     * 插入阅读时长
     * @param r
     */
    @Insert("insert into read_time(user_id,day_time) values(#{userId},#{dayTime})")
    void insert(ReadTime r);

    /**
     * 更新阅读时长
     * @param rd
     */
    @Update("update read_time set day_time = #{dayTime} where user_id = #{userId}")
    void updateById(ReadTime rd);

    /**
     * 查询所有阅读时长
     * @return
     */
    @Select("select * from read_time")
    List<ReadTime> selectAll();

}
